

class Money implements Cloneable{
    public double m=19.9;

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}

class Person implements Cloneable{
    public String name;
    public int age;

    public Person(int age, String name) {
        this.age = age;
        this.name = name;
    }
    Money money=new Money();
    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        Person tmp=(Person) super.clone();
        tmp.money=(Money) this.money.clone();
        return tmp;
    }
}

public class Test {
    public static void main(String[] args) throws CloneNotSupportedException {
        Person person = new Person(10, "zz");
        Person person1 = (Person) person.clone();
        System.out.println("==============");
        person.money.m = 99.9;
        System.out.println(person1.money.m);
        System.out.println(person.money.m);


    }
}
